﻿using AntUnion.FrameWork.Model.Models;
using AntUnion.FrameWork.Util;
using System;

namespace AntUnion.FrameWork.Web.Common
{
    public static class LogHelper
    {
        /// <summary>
        /// 记录错误日志
        /// </summary>
        /// <param name="_context"></param>
        /// <param name="Type">错误类型，如：ex（异常）或 er（其它错误）默认（ex）</param>
        /// <param name="Message">错误信息</param>
        /// <param name="Controller"></param>
        /// <param name="Action"></param>
        /// <param name="Place">出错的位置（如：窗体名称）</param>
        /// <param name="Operation">出错的操作（在执行什么操作时出错）</param>
        /// <param name="Developer">开发者名称拼音缩写，例：zs（张三）</param>
        public static void ErrorLog(mtContext _context, string Type, string Message,string Controller,string Action, string Operation)
        {
            try
            {
                TbErrorlog tbErrorlog = new TbErrorlog();
                tbErrorlog.ErType = Type;
                tbErrorlog.ErMessage = Message;
                tbErrorlog.ErAction = Action;
                tbErrorlog.ErController = Controller;
                tbErrorlog.ErDeveloper = Operation;
                tbErrorlog.ErCreateTime = DateTime.Now;
                _context.TbErrorlogs.Add(tbErrorlog);
                _context.SaveChanges();
            }
            catch
            {
            }
        }

    }
}
